//-
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

include /app/helpers/jade/mixins

-var form = 'rebalance'
-var model = '$ctrl.clonedCache'

panel-collapsible(
    ng-form=form
    on-open=`ui.loadPanel('${form}')`
    ng-hide=`${model}.cacheMode === "LOCAL"`
)
    panel-title Rebalance
    panel-description
        | Cache rebalance settings.
        a.link-success(href="https://apacheignite.readme.io/docs/rebalancing" target="_blank") More info
    panel-content.pca-form-row(ng-if=`ui.isPanelLoaded('${form}')`)
        .pca-form-column-6.pc-form-grid-row
            .pc-form-grid-col-30
                +form-field__dropdown({
                    label: 'Mode:',
                    model: `${model}.rebalanceMode`,
                    name: '"rebalanceMode"',
                    placeholder: 'ASYNC',
                    options: '[\
                        {value: "SYNC", label: "SYNC"},\
                        {value: "ASYNC", label: "ASYNC"},\
                        {value: "NONE", label: "NONE"}\
                    ]',
                    tip: 'Rebalance modes\
                        <ul>\
                            <li>Synchronous - in this mode distributed caches will not start until all necessary data is loaded from other available grid nodes</li>\
                            <li>Asynchronous - in this mode distributed caches will start immediately and will load all necessary data from other available grid nodes in the background</li>\
                            <li>None - in this mode no rebalancing will take place which means that caches will be either loaded on demand from persistent store whenever data is accessed, or will be populated explicitly</li>\
                        </ul>'
                })
            .pc-form-grid-col-30
                +form-field__number({
                    label: 'Batch size:',
                    model: `${model}.rebalanceBatchSize`,
                    name: '"rebalanceBatchSize"',
                    placeholder: '512 * 1024',
                    min: '1',
                    tip: 'Size (in bytes) to be loaded within a single rebalance message<br/>\
                          Rebalancing algorithm will split total data set on every node into multiple batches prior to sending data'
                })
            .pc-form-grid-col-30
                +form-field__number({
                    label: 'Batches prefetch count:',
                    model: `${model}.rebalanceBatchesPrefetchCount`,
                    name: '"rebalanceBatchesPrefetchCount"',
                    placeholder: '2',
                    min: '1',
                    tip: 'Number of batches generated by supply node at rebalancing start'
                })
            .pc-form-grid-col-30
                +form-field__number({
                    label: 'Order:',
                    model: `${model}.rebalanceOrder`,
                    name: '"rebalanceOrder"',
                    placeholder: '0',
                    min: 'Number.MIN_SAFE_INTEGER',
                    tip: 'If cache rebalance order is positive, rebalancing for this cache will be started only when rebalancing for all caches with smaller rebalance order (except caches with rebalance order 0) will be completed'
                })
            .pc-form-grid-col-20
                +form-field__number({
                    label: 'Delay:',
                    model: `${model}.rebalanceDelay`,
                    name: '"rebalanceDelay"',
                    placeholder: '0',
                    min: '0',
                    tip: 'Delay in milliseconds upon a node joining or leaving topology (or crash) after which rebalancing should be started automatically'
                })
            .pc-form-grid-col-20
                +form-field__number({
                    label: 'Timeout:',
                    model: `${model}.rebalanceTimeout`,
                    name: '"rebalanceTimeout"',
                    placeholder: '10000',
                    min: '0',
                    tip: 'Rebalance timeout in milliseconds'
                })
            .pc-form-grid-col-20
                +form-field__number({
                    label: 'Throttle:',
                    model: `${model}.rebalanceThrottle`,
                    name: '"rebalanceThrottle"',
                    placeholder: '0',
                    min: '0',
                    tip: 'Time in milliseconds to wait between rebalance messages to avoid overloading of CPU or network'
                })
        .pca-form-column-6
            +preview-xml-java(model, 'cacheRebalance')
